<?php
/* @var $this CategoryController */
/* @var $model Category */

$this->breadcrumbs=array(
	'Categories'=>array('index'),
	$model->title,
);

$this->menu=array(
	array('label'=>'List Category', 'url'=>array('index')),
	array('label'=>'Create Category', 'url'=>array('create')),
	array('label'=>'Update Category', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Category', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Category', 'url'=>array('admin')),
);
?>

<div class="row">
    <div class="page-header">
        <h1>Товары категории <?php echo $model->title?></h1>
    </div>
</div>
<div class="row">
    <table class="table table-hover table-bordered table-striped">
        <thead>
        <tr>
            <th>Название товара</th>
            <th>Дата создания</th>
            <th>Родительская категория</th>
            <th>Цена</th>
            <th>В наличии</th>
            <th>Управление товаром</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($model->products as $product):?>
            <tr>
                <td><?php echo $product->title; ?></td>
                <td><?php echo $product->created_at; ?></td>
                <td><?php echo $product->category_id == 0 ? "Корневая категория" : Category::model()->findByPk($product->category_id)->title; ?></td>
                <td>    <?php
                    $this->widget('editable.Editable', array(
                        'type' => 'text',
                        'name' => 'product_price',
                        'pk' => $product->id,
                        'text' => $product->price,
                        'url' => $this->createUrl('/obnovit/tovar', array('id' => $product->id)),
                        'title' => 'Введите новое значение',
                        'placement' => 'right'
                    ));
                    ?></td>
                <td> <?php
                    $this->widget('editable.EditableField', array(
                        'type' => 'select',
                        'model' => Product::model()->findByPk($product->id),
                        'attribute' => 'is_present',
                        'url' => $this->createUrl('/obnovit/tovar', array('id' => $product->id)),
                        'source' => Editable::source(array('0' => 'Нет', '1' => 'Да')),
                        'title' => 'Товар в наличии',
                        'placement' => 'right',
                    ));
                    ?></td>
                <td>
                    <?php echo CHtml::link('<span class="glyphicon glyphicon-pencil"></span>', array($this->createUrl('/obnovit/tovar', array('id'=>$product->id))), array('class' => 'btn-sm btn-warning')); ?>
                    <?php echo CHtml::link('<span class="glyphicon glyphicon-remove"></span>', "#", array(
                        'submit'=>array('/udalit/tovar', 'id'=>$product->id),
                        'class' => 'btn-sm btn-danger',
                        'confirm' => 'Вы действительно хотите удалить товар "'.$product->title.'"?',
                        'csrf' => true)); ?>
                </td>
            </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</div>
<div class="row buttons">
    <?php echo CHtml::link('<span class="glyphicon glyphicon-plus"></span> Добавить', array($this->createUrl('/dobavit/tovar')), array('class' => 'btn btn-info')); ?>
</div>

